package com.hmkj.quartz.job;

import com.hmkj.core.service.cache.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 * 充值处理定时器
 *
 * @author Vector
 * @create 2017-09-20 14:39
 */
@Slf4j
//@Component
public class RechargeJob {
    @Resource
    private RedisService redisService;

    /**
     * 充值超时处理
     */
    @Scheduled(fixedDelay = 1000 * 60)// 上次任务执行完后隔1分钟再执行
    public void payExpiredTender() {
//        // 超时时长，单位：分钟 默认30分钟
//        Integer expired = redisService.get(ConfigNID.RECHARGE_EXPIRED, Integer.class);
//        int cashExpired = expired == null ? 30 : expired.intValue();
//        Date expiredTime = DateUtil.offsetMinute(new Date(), -cashExpired);
//        List<Recharge> list = rechargeService.selectExpired(expiredTime);
//        if (CollectionUtils.isNotEmpty(list)) {
//            for (Recharge recharge : list) {
//                try {
//                    rechargeService.updateByPrimaryKeySelective(new Recharge(r -> {
//                        r.setId(recharge.getId());
//                        r.setStatus(Recharge.STATUS.T4.code);
//                    }));
//                } catch (Exception e) {
//                    log.error("充值超时处理定时器处理失败：充值ID：" + recharge.getId() + ",信息：" + e.getMessage());
//                    e.printStackTrace();
//                }
//            }
//        }
    }
}
